- Static display
- good for publication
- effective to show very specific pattern
- Interactive display
- gives end user more flexibility
- exploratory visualization is convenient
November 28, 2023
R packages for this lectureinstall.packages(c("ggplot2","plotly", "DT", "gapminder"))
gapminder packagelibrary(gapminder) dat <- subset(gapminder, year==2007)
library(ggplot2) p <- ggplot(dat, aes(x = log(gdpPercap), y = lifeExp))+ geom_point(aes(size = sqrt(pop/pi)), pch = 21, show.legend = FALSE) + scale_size_continuous(range=c(1,30)) + aes(fill = continent) p
library(plotly) ggplotly(p + aes(label = country))
q <- ggplot(gapminder, aes(x = log(gdpPercap), y = lifeExp, frame=year))+ geom_point(aes(size = sqrt(pop/pi)), pch = 21, show.legend = FALSE) + scale_size_continuous(range=c(1,30)) + aes(fill = continent) ggplotly(q + aes(label = country))
plot_ly(gapminder, x = ~gdpPercap, y = ~lifeExp, z = ~continent) %>% add_markers(color = ~continent)
library(leaflet)
leaflet() %>%
addTiles() %>% # use the default base map which is OpenStreetMap tiles
addMarkers(lat = 41.257876, lng = -96.012557,
popup = "University of Nebraska Omaha")